package com.ruoyi.zdtj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zdtj.domain.payment;
import com.ruoyi.zdtj.service.IpaymentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账单统计Controller
 * 
 * @author zh
 * @date 2025-06-06
 */
@RestController
@RequestMapping("/zdtj/zdtj")
public class paymentController extends BaseController
{
    @Autowired
    private IpaymentService paymentService;

    /**
     * 查询账单统计列表
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:list')")
    @GetMapping("/list")
    public TableDataInfo list(payment payment)
    {
        startPage();
        List<payment> list = paymentService.selectpaymentList(payment);
        return getDataTable(list);
    }

    /**
     * 导出账单统计列表
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:export')")
    @Log(title = "账单统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, payment payment)
    {
        List<payment> list = paymentService.selectpaymentList(payment);
        ExcelUtil<payment> util = new ExcelUtil<payment>(payment.class);
        util.exportExcel(response, list, "账单统计数据");
    }

    /**
     * 获取账单统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(paymentService.selectpaymentById(id));
    }

    /**
     * 新增账单统计
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:add')")
    @Log(title = "账单统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody payment payment)
    {
        return toAjax(paymentService.insertpayment(payment));
    }

    /**
     * 修改账单统计
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:edit')")
    @Log(title = "账单统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody payment payment)
    {
        return toAjax(paymentService.updatepayment(payment));
    }

    /**
     * 删除账单统计
     */
    @PreAuthorize("@ss.hasPermi('zdtj:zdtj:remove')")
    @Log(title = "账单统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(paymentService.deletepaymentByIds(ids));
    }
}
